package cate.game.role.res.call.normal;

import cate.common.table.d.GDHeroCall;

import cate.game.role.Role;
import cate.game.role.res.call.*;
import cate.game.role.res.call.base.CallProcessData;
import cate.game.role.res.call.base.ICallExe;
import cate.game.role.res.call.base.ICallHandler;
import easy.java.dev.note.NoteClass;


@NoteClass(value = "普通召唤")
public class CallNormalCallPO extends CallBasePO implements ICallExe {
    public CallNormalCallPO() {
    }

    @Override
    public void initialize(Role role, CallTool tool) {
        super.initialize(role, tool);
        role.getRes().callPO.register(getMode(), this);
    }

    @Override
    protected byte getMode() {
        return GDHeroCall.Mode.NORMAL;
    }

    @Override
    public void handleResult(Role role, CallProcessData processData, ICallHandler handler, CallBasePO po) {
        if (!handler.calcResult(role, processData, po).ok()) {
            return;
        }
        tool.updatePo(role, processData, po);
        tool.sacrificeHero(role, processData);
        tool.sendResultToRole(role, processData);
        tool.sendHeroCallResp(role, processData, po);
        tool.lampOnline(role, processData);
        this.noticeUpdate(role);
    }


    @Override
    public void modifyByMods(Role role, CallProcessData processData, ICallHandler handler, CallBasePO basePO) {
        tool.ensureFiveHeroPool(role, processData, basePO);
        tool.addAllScore(role, processData);
        ICallExe.super.modifyByMods(role, processData, handler, basePO);
    }

    @Override
    protected void noticeUpdate(Role role) {
        this.role.getRes().callPO.noticeCallDataUpdate();
    }

    @Override
    public CallNormalCallPO onGotPO(Role role) {
        return role.getRes().callPO.normal;
    }
}
